package com.wy.count_down_latch_demo;
import java.util.concurrent.CountDownLatch;

public class Main {
    // count: 计数器为 3 个，只有 3 个全部报到了，门闩才会打开
    static CountDownLatch countDownLatch = new CountDownLatch(3);


    static class MyThread extends Thread {
        @Override
        public void run() {
            countDownLatch.countDown();
            countDownLatch.countDown();
            countDownLatch.countDown();
        }
    }

    public static void main(String[] args) throws InterruptedException {
        MyThread t = new MyThread();
        t.start();

        countDownLatch.await();

        System.out.println("门闩被打开了");
    }
}